package com.sysu.homework.service.Impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.sysu.homework.DAO.CourseDAO;
import com.sysu.homework.model.Course;
import com.sysu.homework.service.CourseService;

@Component
public class CourseServiceImpl implements CourseService {

	private CourseDAO courseDAO;
	
	@Override
	public int addCourse(Course course) {
		if(course != null)
			return courseDAO.save(course);
		return -1;
	}

	@Override
	public Course getCourseById(int id) {
		if (id !=0)
			return courseDAO.getCourseById(id);
		return null;
	}

	@Resource
	public void setCourseDAO(CourseDAO courseDAO) {
		this.courseDAO = courseDAO;
	}

	public CourseDAO getCourseDAO() {
		return courseDAO;
	}

}
